<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 创建数组
        var arr = [0,1,0,0,2,2,0,0,0,3,3,3,0,0,0,0,4,0,0,0,0,0,5]
        // 创建函数
        function delN(arr,num) {
            var newArr = [];
            for (var i = 0; i < arr.length; i++) {
                // 如果不是 0 ，添加到新的数组
                if (arr[i] != num) {
                    newArr.push(arr[i]);
                }
            }
            return newArr;
        }
        console.log(delN(arr,0))
    </script>
</head>
<body>
    
</body>
</html>